package com.sskj.mine.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.bean.PayWayBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.ui.activity.SecurityCenterActivity;

import java.util.List;


public class SecurityCenterActivityPresenter extends BasePresenter<SecurityCenterActivity> {

    public void getPayType() {
        httpService.getPayType()
                .execute(new JsonCallBack<HttpData<PayWayBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<PayWayBean>> response) {
                        HttpData<PayWayBean> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.setPayType(httpData.getData().getPay_list());
                        }
                    }
                });
    }

    public void toggleShop() {
        httpService.applyShop("5")
                .execute(new JsonCallBack<HttpData>(this) {
                    @Override
                    public void onSuccess(Response<HttpData> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.toggleShopSuccess();
                        }
                    }
                });
    }

    public void togglePay(String type, String val) {
        httpService.togglePayType(type, val)
                .execute(new JsonCallBack<HttpData<Object>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<Object>> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.getMsg());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.togglePayTypeSuccess();
                        }
                    }
                });
    }
}
